<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>">
<%@include file="/views/global/ShopInclude.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="static/css/page/buyerManagement.css" rel="stylesheet" type="text/css">
<link href="static/css/page/category.css" rel="stylesheet" type="text/css">
<title>FAVORITE</title>
</head>
<body class="submitBg">
<!-- 顶部导航条  -->
<%@include file="/views/global/header.jsp" %>
<!-- 顶部导航条结束  -->

<c:set var="pageName" value="favorite"></c:set>
<%@include file="/views/global/BuyerHeader.jsp" %>

  <div class="submitFormContainer center font fontColorGray">  <!-- 表单填写部分 -->
    <form id="submitFavoriteForm" name="submitFavoriteForm" class="submitForm" action="${actionPath }" method="post">
      <input type="hidden" name="origin" value="${origin }"/>
      <div class="submitFormTitle font fontColorGray hrTableBorder">
        <ul class="favoriteClassify">
          <c:choose>
             <c:when test="${origin eq 'SHOP_LIKE' }">
               <a href="javascript:void(0)" onclick="goToFavorit('ITEM_LIKE')"><li>喜爱的宝贝 FAVORITE ITEM</li></a>
               <a href="javascript:void(0)" onclick="goToFavorit('SHOP_LIKE')" class="submitPageActive"><li>喜爱的店铺 FAVORITE STORE</li></a>
             </c:when>
             <c:otherwise>
               <a  onclick="goToFavorit('ITEM_LIKE')" class="submitPageActive"><li>喜爱的宝贝 FAVORITE ITEM</li></a>
               <a onclick="goToFavorit('SHOP_LIKE')" ><li>喜爱的店铺 FAVORITE STORE</li></a>
             </c:otherwise>
          </c:choose>
        </ul>
      </div>
      <ul class="favoriteSubClassify font fontColorGray">
        <a class="submitPageActive"><li>全部 ALL<span style="margin: 0px 12px;">${pagination.totalSize }<span>
         <div class="pagination-simple">
			<pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }" formName="submitFavoriteForm"  className="pagination-prev"></pagination:pagenav>
		    </div>
        </li></a> 
      </ul>
        <div class="favoriteContent">
          <ul class="favoriteItemsList">
            <c:forEach var="item" items="${dataList }">
               <c:choose>
                  <c:when test="${origin eq 'SHOP_LIKE' }">
                    <li class="favoriteItem">
		              <a href="seller/sellerHome?sellerId=${item.id }">
		                 <img class="favoriteItemImg" src="${fileServerBasePath }download/${item.sellerFileId }"/>
		              </a>
		              <a href="seller/sellerHome?sellerId=${item.id }"><div class="favoriteItemName">${item.storeName }</div></a>
		              <div class="favoriteItemPrice">${item.sellerName }</div>
		              <a href="javascript:void(0)" onclick="unlike('${item.userId}','SHOP_LIKE')">
		                  <div class="favoriteItemDelBtn">删除DEL</div>
		              </a>
		            </li>
                  </c:when>
                  <c:otherwise>
                   <li class="favoriteItem">
		              <a href="item/detail?id=${item.id }">
		                <img class="favoriteItemImg" src="${item.mainUrl }"/>
		              </a>
		              <a href="item/detail?id=${item.id }"><div class="favoriteItemName">${item.title }<br/>${item.cnName }</div></a>
		              <div class="favoriteItemPrice">RMB ${item.price }</div>
		              <a href="javascript:void(0)" onclick="unlike('${item.id}','ITEM_LIKE')">
		                  <div class="favoriteItemDelBtn">删除DEL</div>
		              </a>
		            </li>
                  </c:otherwise>
               </c:choose>
            </c:forEach>
          </ul>
      
       
          <!-- 页码结束 -->
               
        </div>     
      
    </form>
  </div>
<!-- 页尾 -->
<%@include file="/views/global/AdminScripts.jsp" %>
<%@include file="/views/global/footer.jsp" %>
<!-- 页尾结束 -->
<script type="text/javascript">
function switchPage(pageNo){
	$("INPUT[name='pageIndex']", "#submitFavoriteForm").val(pageNo);
	document.forms["submitFavoriteForm"].submit();
}

function goToFavorit(origin){
	$("INPUT[name='origin']", "#submitFavoriteForm").val(origin);
	document.forms["submitFavoriteForm"].submit();
}
function unlike(id,origin){
	if('SHOP_LIKE' == origin){
		$.postEx("seller/statistics/like", 
				{sellerId: id}, 
			function(jsonData){
			if(false == jsonData.success){
				$.error(jsonData.message);
			} else {
				window.location.reload();
			}
		}, "json");
	}else if('ITEM_LIKE' == origin){
		$.postEx("item/statistics/like", 
				{itemId: id}, 
			function(jsonData){
			if(false == jsonData.success){
				$.error(jsonData.message);
			} else {
				window.location.reload();
			}
		}, "json");
	}
	
	
	
}
$(document).ready(function(){
	
});
</script>
</body>

</html>
